#include "point.h"

point::point(): x(0.0), y(0.0)
{
}

point::point(double x, double y): x(x), y(y)
{
}

bool point::operator==(const point &p) const
{
    return (x == p.x) && (y == p.y);
}

bool point::operator!=(const point &p) const
{
    return !(*this == p);
}

point &point::operator+=(const point &p)
{
    x += p.x;
    x += p.y;

    return *this;
}

point &point::operator-=(const point &p)
{
    x -= p.x;
    y -= p.y;

    return *this;
}

point point::operator+(const point &p) const
{
    point tmp = *this;
    tmp += p;

    return tmp;
}

point point::operator-(const point &p) const
{
    point tmp = *this;
    tmp -= p;

    return tmp;
}

bool point_comparator::operator()(const point &a, const point &b) const
{
    return (t == X) ? (a.x < b.x) : (a.y < b.y);
}

std::istream &operator>>(std::istream &is, point &p)
{
    is >> p.x >> p.y;

    return is;
}

std::ostream &operator<<(std::ostream &os, const point &p)
{
    os << p.x << " " << p.y;

    return os;
}
